tempiso 2.2.2
Loading...
Searching...
No Matches
tempiso.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2026 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef TEMPISO_H
29#define TEMPISO_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_analog_in.h"
52
58
63
68
73#define TEMPISO_NUM_CONVERSIONS 100
74
79#define TEMPISO_VREF_3V3 3.3
80#define TEMPISO_VREF_5V 5.0
81
86#define TEMPISO_TIMEOUT_MS 2000
87
92#define TEMPISO_TEMP_SENS_V_PER_C 0.01f
93#define TEMPISO_TEMP_ZERO_OFFSET_V 0.5f
94 // tempiso_set
96
101
106
111#define TEMPISO_MAP_MIKROBUS( cfg, mikrobus ) \
112 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN );
113 // tempiso_map // tempiso
116
121typedef struct
122{
123 analog_in_t adc;
124
125} tempiso_t;
126
131typedef struct
132{
133 pin_name_t an;
134
135 analog_in_resolution_t resolution;
136 float vref;
137
139
144typedef enum
145{
148
150
156
167
182
194err_t tempiso_read_raw_adc ( tempiso_t *ctx, uint16_t *raw_adc );
195
207err_t tempiso_read_voltage ( tempiso_t *ctx, float *voltage );
208
221err_t tempiso_read_voltage_avg ( tempiso_t *ctx, uint16_t num_conv, float *voltage_avg );
222
234err_t tempiso_set_vref ( tempiso_t *ctx, float vref );
235
248err_t tempiso_read_temperature ( tempiso_t *ctx, float *data_out );
249
250#ifdef __cplusplus
251}
252#endif
253#endif // TEMPISO_H
254 // tempiso
256
257// ------------------------------------------------------------------------ END
err_t tempiso_read_raw_adc(tempiso_t *ctx, uint16_t *raw_adc)
Temp ISO read raw ADC value function.
void tempiso_cfg_setup(tempiso_cfg_t *cfg)
Temp ISO configuration object setup function.
err_t tempiso_read_voltage(tempiso_t *ctx, float *voltage)
Temp ISO read voltage level function.
err_t tempiso_read_voltage_avg(tempiso_t *ctx, uint16_t num_conv, float *voltage_avg)
Temp ISO read average voltage level function.
err_t tempiso_set_vref(tempiso_t *ctx, float vref)
Temp ISO set vref function.
err_t tempiso_read_temperature(tempiso_t *ctx, float *data_out)
Temp ISO read temperature function.
err_t tempiso_init(tempiso_t *ctx, tempiso_cfg_t *cfg)
Temp ISO initialization function.
Temp ISO Click configuration object.
Definition tempiso.h:132
analog_in_resolution_t resolution
Definition tempiso.h:135
float vref
Definition tempiso.h:136
pin_name_t an
Definition tempiso.h:133
Temp ISO Click context object.
Definition tempiso.h:122
analog_in_t adc
Definition tempiso.h:123
tempiso_return_value_t
Temp ISO Click return value data.
Definition tempiso.h:145
@ TEMPISO_OK
Definition tempiso.h:146
@ TEMPISO_ERROR
Definition tempiso.h:147